<template>
	<view class="page">
		<view class="head-container">
            <view class="user-wrapper">
                <view class="avator-wrapper">
                    <image :src="default_avtator"
                        mode="aspectFill" 
                        style="width: 180rpx;height: 180rpx;"></image>
                </view>
                <view class="user-info">
                    <view>{{info.nickName}}</view>
                    <view>{{info.phonenumber}}</view>
                </view>
            </view>
        </view>
        <view class="user-list">
            <uni-list>
            	<!-- <uni-list-item 
                    title="我的收藏" 
                    link
                    thumbSize="sm"
					thumb="../../static/favor.png"
                    @click="handleLinkFavor" ></uni-list-item> -->
            	<uni-list-item 
                    title="退出登录" 
                    link="reLaunch" 
                    thumbSize="sm"
					thumb="../../static/logout.png"
                    @click="logout" ></uni-list-item>
            </uni-list>
        </view>
	</view>
</template>

<script>
    import { getInfo , logout } from '@/api/login.js'
	export default {
		data() {
			return {
				info: {},
                roles: [],
                base_url: 'http://120.46.187.217/medical_notes',
                default_avtator: require('@/static/default-avator.png')
			}
		},
        onLoad() {
            this.handleGetUserInfo()
        },
		methods: {
			handleGetUserInfo() {
                getInfo().then(res => {
                    this.info = res.user
                    this.roles = res.roles
                })
            },
            handleLinkFavor() {
                
            },  
            logout() {
                uni.showModal({
                	title: '提示',
                	content: '确定退出当前用户吗？',
                	success: function (res) {
                		if (res.confirm) {
                			logout().then(res => {
                                uni.reLaunch({
                                    url: '/pages/login/login'
                                })
                            })
                		}
                	}
                });
            }
		}
	}
</script>

<style lang="less">
	@import url('./mine.less');
</style>
